/**
 * 
 */
package botactions;

import bot.IRCBot;
import botactions.IRCServerTypeAction;

/**
 * @author Philip
 *
 */
public class NickAction implements IRCServerTypeAction {

	@Override
	public void execute(IRCBot bot, String line) {
		String[] segments = line.split(" ");
		
		String sender = segments[0].substring(1, segments[0].substring(1).indexOf("!") + 1);
		String nickName = segments[2].substring(1);
		
				
		if (sender.equals(bot.getNickName()) && !nickName.equals(bot.getNickName()) && segments[2].contains(":")) {
			bot.setNickName(nickName);
		}
	}
}